# -*- coding: utf8 -*-

import unittest

from equipment import Equipment
from human import Player
from item import Item
from pocket import Bag

class BagTest(unittest.TestCase):
    def test_bag_should_be_containable(self):
        bag = Bag()
        self.assertEqual(len(bag.items), 0)

        yao = Item(hp=10)
        self.failUnless(bag.addItem(yao))
        self.assertEqual(len(bag.items), 1)
        self.assertEqual(bag.items[0], yao)

    def test_bag_should_not_contain_people(self):
        bag = Bag()
        person = Player(mhp=10, hp=10)

        self.failIf(bag.addItem(person))
        self.assertEqual(len(bag.items), 0)

    def test_bag_should_not_contain_more_then_10_items(self):
        bag = Bag()

        for i in range(10):
            item = Item(hp=1)
            self.failUnless(bag.addItem(item))
        self.assertEqual(len(bag.items), 10)

        item = Item(hp=1)
        self.failIf(bag.addItem(item))
        self.assertEqual(len(bag.items), 10)
        
    def test_bag_should_be_indexable(self):
        bag = Bag()
        item = Item(hp=1)
        bag.addItem(item)
        
        get = bag.index(0)
        
        self.assertEqual(item, get)
    
    def test_bag_should_be_drop(self):
        bag = Bag()
        item = Item(hp=1)
        bag.addItem(item)
        self.assertEqual(len(bag.items), 1)
        bag.drop(0)
        self.assertEqual(len(bag.items), 0)

if __name__ == '__main__':
    unittest.main()
